/**
 *     tipple is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    tipple is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with tipple.  If not, see <http://www.gnu.org/licenses/>.
 * Copyright 2009 James Osler, Adam Tomkins

 */



package v0_4;

//~--- JDK imports ------------------------------------------------------------

import java.io.*;

/**
 * Simply writes an added beer to the file on a new line, in the correct format.
 * Constructor uses the variables passed to it, no error checking.
 * There is however, a error catching loop.
 */
public class Filewrite {
    BufferedWriter out;

    public Filewrite(int newid, String newName, double newPercent, int newVolume, double newCost) {
        try {
            out = new BufferedWriter(new FileWriter("Beer.txt", true));
            out.newLine();
            out.write(newid + "-" + newName + "-" + newPercent + "-" + newVolume + "-" + newCost);
            out.close();
        } catch (IOException e) {
            System.out.println("There was a problem:" + e);
        }
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
